/*
 * price_model.cpp
 *
 *  Created on: Apr 1, 2009
 *      Author: Lev
 */

#include <cmath>
#include "price_model.hpp"
using namespace std;

void StockPriceModel::resetProps( const SPModelProps& props ) {
	_s0 = props.s0;
	_mu = props.mu;
	_sigma = props.sigma;
	_sT = _s0;
}

double StockPriceModel::getNextPrice( double dt ) throw(invalid_argument){
	if( dt <= 0.0 )
		throw( "dt should be GT 0" );
	double random = _random.next();
	_sT *= exp( (_mu - _sigma*_sigma/2.0)*dt + _sigma*sqrt( dt )*random );
	return _sT;
}

